﻿<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="Microsoft.Help.SelfBranded" content="true" />
    <meta name="Language" content="en-us" />
    <meta name="Microsoft.Help.Locale" content="en-us" />
    <meta name="Microsoft.Help.TopicLocale" content="en-us" />
    <link rel="shortcut icon" href="../icons/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="../styles/branding.css" />
    <link rel="stylesheet" type="text/css" href="../styles/branding-en-US.css" />
    <script type="text/javascript" src="../scripts/branding.js"></script>
    <title>IniHelp.SetItems Method</title>
    <meta name="Title" content="SetItems Method" />
    <meta name="Microsoft.Help.Id" content="M:SosoMS.Common.FileHelp.IniHelp.SetItems(System.String,System.String,System.String[])" />
    <meta name="Microsoft.Help.ContentType" content="Reference" />
    <meta name="System.Keywords" content="IniHelp.SetItems method" />
    <meta name="System.Keywords" content="SetItems method" />
    <meta name="Microsoft.Help.F1" content="SosoMS.Common.FileHelp.IniHelp.SetItems" />
    <meta name="Microsoft.Help.F1" content="IniHelp.SetItems" />
    <meta name="Microsoft.Help.F1" content="SetItems" />
    <meta name="container" content="SosoMS.Common.FileHelp" />
    <meta name="file" content="d6d9500d-97b9-e4e5-3f6a-c720af241dce" />
    <meta name="guid" content="d6d9500d-97b9-e4e5-3f6a-c720af241dce" />
    <meta name="Microsoft.Help.Category" content="CSharp" />
    <meta name="Microsoft.Help.Category" content="ini" />
    <meta name="Description" content="往指定的节点中写入键值对" />
    <link type="text/css" rel="stylesheet" href="../styles/highlight.css" />
    <script type="text/javascript" src="../scripts/highlight.js"> </script>
    <link rel="stylesheet" type="text/css" href="../styles/branding-Help1.css" />
  </head>
  <body onload="SetDefaultLanguage('cs');">
    <input type="hidden" id="userDataCache" class="userDataStyle" />
    <div id="PageHeader" class="pageHeader">嗖嗖常用方法帮助集</div>
    <div class="pageBody">
      <div id="TopicContent" class="topicContent">
        <table class="titleTable">
          <tr>
            <td class="titleColumn">
              <h1>Ini<wbr />Help<span id="LSTAAA98967_0" data-languageSpecificText="cpp=::|nu=."></span>Set<wbr />Items Method</h1>
            </td>
          </tr>
        </table>
        <div class="summary">
            往指定的节点中写入键值对
            </div>
        <br />
        <strong>Namespace:</strong> <a href="4f2fecb0-966c-232d-a819-c35018f8ad72.htm">SosoMS.Common.FileHelp</a><br /><strong>Assembly:</strong> SosoMS.Common (in SosoMS.Common.dll) Version: 1.0.0<div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('IDB')" onkeypress="SectionExpandCollapse_CheckKey('IDB', event)" tabindex="0"><img id="IDBToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Syntax</span></div><div id="IDBSection" class="collapsibleSection"><div id="IDAB" class="codeSnippetContainer"><div class="codeSnippetContainerTabs"><div id="IDAB_tab1" class="codeSnippetContainerTab"><a href="#" onclick="ChangeTab('IDAB','cs','1','4');return false;">C#</a></div><div id="IDAB_tab2" class="codeSnippetContainerTab"><a href="#" onclick="ChangeTab('IDAB','vb','2','4');return false;">VB</a></div><div id="IDAB_tab3" class="codeSnippetContainerTab"><a href="#" onclick="ChangeTab('IDAB','cpp','3','4');return false;">C++</a></div><div id="IDAB_tab4" class="codeSnippetContainerTab"><a href="#" onclick="ChangeTab('IDAB','fs','4','4');return false;">F#</a></div></div><div class="codeSnippetContainerCodeContainer"><div class="codeSnippetToolBar"><div class="codeSnippetToolBarText"><a id="IDAB_copyCode" href="#" class="copyCodeSnippet" onclick="CopyToClipboard('IDAB');return false;" title="Copy">Copy</a></div></div><div id="IDAB_code_Div1" class="codeSnippetContainerCode" style="display: block"><pre xml:space="preserve"><span class="keyword">public</span> <span class="keyword">static</span> <span class="identifier">bool</span> <span class="identifier">SetItems</span>(
	<span class="identifier">string</span> <span class="parameter">iniFileName</span>,
	<span class="identifier">string</span> <span class="parameter">section</span>,
	<span class="keyword">params</span> <span class="identifier">string</span>[] <span class="parameter">items</span>
)</pre></div><div id="IDAB_code_Div2" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">Public</span> <span class="keyword">Shared</span> <span class="keyword">Function</span> <span class="identifier">SetItems</span> ( 
	<span class="parameter">iniFileName</span> <span class="keyword">As</span> <span class="identifier">String</span>,
	<span class="parameter">section</span> <span class="keyword">As</span> <span class="identifier">String</span>,
	<span class="keyword">ParamArray</span> <span class="parameter">items</span> <span class="keyword">As</span> <span class="identifier">String</span>()
) <span class="keyword">As</span> <span class="identifier">Boolean</span></pre></div><div id="IDAB_code_Div3" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">public</span>:
<span class="keyword">static</span> <span class="identifier">bool</span> <span class="identifier">SetItems</span>(
	<span class="identifier">String</span>^ <span class="parameter">iniFileName</span>, 
	<span class="identifier">String</span>^ <span class="parameter">section</span>, 
	... <span class="keyword">array</span>&lt;<span class="identifier">String</span>^&gt;^ <span class="parameter">items</span>
)</pre></div><div id="IDAB_code_Div4" class="codeSnippetContainerCode" style="display: none"><pre xml:space="preserve"><span class="keyword">static</span> <span class="keyword">member</span> <span class="identifier">SetItems</span> : 
        <span class="parameter">iniFileName</span> : <span class="identifier">string</span> * 
        <span class="parameter">section</span> : <span class="identifier">string</span> * 
        <span class="parameter">items</span> : <span class="identifier">string</span>[] <span class="keyword">-&gt;</span> <span class="identifier">bool</span> </pre></div></div></div><h4>Parameters</h4><dl><dt class="has-text-weight-normal"><span class="parameter">iniFileName</span>  <a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a></dt><dd>文件名</dd><dt class="has-text-weight-normal"><span class="parameter">section</span>  <a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a></dt><dd>节点名称</dd><dt class="has-text-weight-normal"><span class="parameter">items</span>  <span id="LSTAAA98967_1" data-languageSpecificText="cpp=array&lt;"></span><a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a><span id="LSTAAA98967_2" data-languageSpecificText="cpp=&gt;|vb=()|nu=[]"></span></dt><dd>键值对</dd></dl><h4>Return Value</h4><a href="https://learn.microsoft.com/dotnet/api/system.boolean" target="_blank" rel="noopener noreferrer">Boolean</a><br />写入成功返回<span class="keyword"><span id="LSTAAA98967_3" data-languageSpecificText="vb=True|nu=true"></span></span>, 失败返回<span class="keyword"><span id="LSTAAA98967_4" data-languageSpecificText="vb=False|nu=false"></span></span></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('IDGC')" onkeypress="SectionExpandCollapse_CheckKey('IDGC', event)" tabindex="0"><img id="IDGCToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Exceptions</span></div><div id="IDGCSection" class="collapsibleSection"><table><tr><th>Exception</th><th>Condition</th></tr><tr><td><a href="https://learn.microsoft.com/dotnet/api/system.argumentnullexception" target="_blank" rel="noopener noreferrer">ArgumentNullException</a></td><td /></tr></table></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('IDBC')" onkeypress="SectionExpandCollapse_CheckKey('IDBC', event)" tabindex="0"><img id="IDBCToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Remarks</span></div><div id="IDBCSection" class="collapsibleSection">
            直接往一个ini文件中的指定节点下，写入一个或多个键值对数据，如果节点不存在就创建该节点。
            </div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('IDCC')" onkeypress="SectionExpandCollapse_CheckKey('IDCC', event)" tabindex="0"><img id="IDCCToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />Example</span></div><div id="IDCCSection" class="collapsibleSection">
            示例数据
            <div id="IDBCC" class="codeSnippetContainer"><div class="codeSnippetContainerTabs"><div id="IDBCC_tab1" class="codeSnippetContainerTabSingle">ini</div></div><div class="codeSnippetContainerCodeContainer"><div class="codeSnippetToolBar"><div class="codeSnippetToolBarText"><a id="IDBCC_copyCode" href="#" class="copyCodeSnippet" onclick="CopyToClipboard('IDBCC');return false;" title="Copy">Copy</a></div></div><div id="IDBCC_code_Div1" class="codeSnippetContainerCode" style="display: block"><pre xml:space="preserve">[Array]
First=第一个
Second = 第二个
Third=第三个
[Base]
First = 第一个
Second=第二个
Third = 第三个</pre></div></div></div>
            使用方法
            <div id="IDDCC" class="codeSnippetContainer"><div class="codeSnippetContainerTabs"><div id="IDDCC_tab1" class="codeSnippetContainerTabSingle">C#</div></div><div class="codeSnippetContainerCodeContainer"><div class="codeSnippetToolBar"><div class="codeSnippetToolBarText"><a id="IDDCC_copyCode" href="#" class="copyCodeSnippet" onclick="CopyToClipboard('IDDCC');return false;" title="Copy">Copy</a></div></div><div id="IDDCC_code_Div1" class="codeSnippetContainerCode" style="display: block"><pre xml:space="preserve"><span class="highlight-keyword">var</span> result = IniHelp.SetItems(fileName, <span class="highlight-literal">"Array"</span>, <span class="highlight-literal">"Forth=第四个"</span>);
<span class="highlight-comment">// 上面语句执行成功后，ini文件中的数据如下：</span>
<span class="highlight-comment">// [Array]</span>
<span class="highlight-comment">// First=第一个</span>
<span class="highlight-comment">// Second = 第二个</span>
<span class="highlight-comment">// Third=第三个</span>
<span class="highlight-comment">// Forth=第四个</span>
<span class="highlight-comment">// [Base]</span>
<span class="highlight-comment">// First = 第一个</span>
<span class="highlight-comment">// Second=第二个</span>
<span class="highlight-comment">// Third = 第三个</span></pre></div></div></div>
            写入多个数据
            <div id="IDFCC" class="codeSnippetContainer"><div class="codeSnippetContainerTabs"><div id="IDFCC_tab1" class="codeSnippetContainerTabSingle">C#</div></div><div class="codeSnippetContainerCodeContainer"><div class="codeSnippetToolBar"><div class="codeSnippetToolBarText"><a id="IDFCC_copyCode" href="#" class="copyCodeSnippet" onclick="CopyToClipboard('IDFCC');return false;" title="Copy">Copy</a></div></div><div id="IDFCC_code_Div1" class="codeSnippetContainerCode" style="display: block"><pre xml:space="preserve"><span class="highlight-keyword">var</span> result = IniHelp.SetItems(fileName, <span class="highlight-literal">"AddData"</span>, <span class="highlight-literal">"Data1=DataOne"</span>, <span class="highlight-literal">"Data2=DataTwo"</span>);
<span class="highlight-comment">// 上面语句执行成功后，ini文件中的数据如下：</span>
<span class="highlight-comment">// [Array]</span>
<span class="highlight-comment">// First=第一个</span>
<span class="highlight-comment">// Second = 第二个</span>
<span class="highlight-comment">// Third=第三个</span>
<span class="highlight-comment">// Forth=第四个</span>
<span class="highlight-comment">// [Base]</span>
<span class="highlight-comment">// First = 第一个</span>
<span class="highlight-comment">// Second=第二个</span>
<span class="highlight-comment">// Third = 第三个</span>
<span class="highlight-comment">// [AddData]</span>
<span class="highlight-comment">// Data1=DataOne</span>
<span class="highlight-comment">// Data2=DataTwo</span></pre></div></div></div></div><div class="collapsibleAreaRegion"><span class="collapsibleRegionTitle" onclick="SectionExpandCollapse('seeAlso')" onkeypress="SectionExpandCollapse_CheckKey('seeAlso', event)" tabindex="0"><img id="seeAlsoToggle" class="collapseToggle" src="../icons/SectionExpanded.png" />See Also</span></div><div id="seeAlsoSection" class="collapsibleSection"><h4>Reference</h4><div><a href="1904b01d-e79f-ed43-8a41-7298709ef479.htm">IniHelp Class</a></div><div><a href="4f2fecb0-966c-232d-a819-c35018f8ad72.htm">SosoMS.Common.FileHelp Namespace</a></div></div></div>
    </div>
    <div id="PageFooter" class="pageFooter" />
  </body>
</html>